//package cn.good.yan.config.security.Filter;
//
//import cn.good.yan.entity.Re;
//import com.fasterxml.jackson.databind.ObjectMapper;
//import org.springframework.security.core.AuthenticationException;
//import org.springframework.security.web.AuthenticationEntryPoint;
//import org.springframework.stereotype.Component;
//
//import javax.servlet.ServletException;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//import java.io.PrintWriter;
//
///**
// * 当未登录 或者 token失效 访问接口时，自定义返回结果
// *
// * @author shengren.yan
// * @create 2024/11/3
// */
//@Component
//public class RestAuthorizationEntryPoint implements AuthenticationEntryPoint {
//
//    @Override
//    public void commence(HttpServletRequest request,
//                         HttpServletResponse response,
//                         AuthenticationException e) throws IOException, ServletException {
//
//        response.setCharacterEncoding("UTF-8");
//        response.setContentType("application/json");
//        PrintWriter out = response.getWriter();
//        Re r = Re.error("尚未登陆，请重新登录！");
//        r.setCode(401);
//        out.write(new ObjectMapper().writeValueAsString(r));
//        out.flush();
//        out.close();
//    }
//
//}
